import request from '@/utils/http'
import type { reqLoginType, responseLoginDataType, responseWeixinLoginDataType } from './type'

enum API {
  USERLOGIN_URL = '/user/login',
  WEIXINLOGIN_URL = '/user/weixin/getLoginParam',
}

/**
 * 用户登录
 *
 * @param data {reqLoginType} 用户登录信息
 */
export const doLoginAPI = (data: reqLoginType) => {
  return request<any, responseLoginDataType>({
    url: API.USERLOGIN_URL,
    method: 'POST',
    data,
  })
}

/**
 * 微信授权登录返回数据
 *
 * wxRedirectUri {string} 重定向路径
 */
export const weixinLoginAPI = (wxRedirectUri: string) => {
  return request<any, responseWeixinLoginDataType>({
    url: API.WEIXINLOGIN_URL,
    params: {
      wxRedirectUri,
    },
  })
}
